const Cesium = window.Cesium;
import { formarColor, COLOR } from "../../Config";


class Label {
    constructor(Entity, options, Offset = {},size) {
        if (!Entity) {
            throw new Error('至少传入一个 Entity 对象');
        };
        this.Entity = Entity;
        this.options = options;
        var FontSize = window.REMFontSize || 1;
        var _label = {
            font: size || parseInt(12 * FontSize) + 'pt Source Han Sans CN', //字体样式
            showBackground: !!this.options.background, //是否显示背景颜色
            // style: Cesium.LabelStyle.FILL, //label样式
            outlineWidth: 0,
            verticalOrigin: Cesium.VerticalOrigin.CENTER, //垂直位置
            horizontalOrigin: Cesium.HorizontalOrigin.CENTER, //水平位置
            pixelOffset: new Cesium.Cartesian2(Offset.OffsetX || 0, Offset.OffsetY || 0), //偏移
            // eyeOffset: new Cesium.Cartesian3(0, 0, 100000),
            disableDepthTestDistance: Number.POSITIVE_INFINITY,
        };

        if (typeof this.options == 'string') {
            _label.text = this.options;
            _label.fillColor = COLOR.LIGHT_BLUE; //字体颜色
            _label.backgroundColor = COLOR.DARK_GREEN; //字体颜色
        } else if (typeof this.options == 'object') {
            _label.text = this.options.text;
            _label.fillColor = formarColor(this.options.color) || COLOR.LIGHT_BLUE;
            _label.backgroundColor = formarColor(this.options.background) || COLOR.DARK_GREEN;
        }

        this.Entity.label = _label;
    }
    set show(type) {
        this.Entity.label.show = !!type;
    }
    get show() {
        return this.Entity.label.show
    }
}



export { Label }